package com.yunji.order.emuns;

import com.yunji.common.utils.bean.BeanUtils;
import lombok.Getter;

import java.util.Objects;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.order.emuns
 * @Title: PayMode
 * @Description: 支付方式
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-04-10 20:03:06      V1.0        HuaAo       新建类
 */

@Getter
public enum PayMode {
    NOT_EXISTS(-1, "无"),
    PURSE(0, "余额支付"),
    WECHAT(1, "微信支付"),
    ALIPAY(2, "阿里支付");
    private final Integer code;
    private final String text;

    PayMode(Integer code, String text) {
        this.code = code;
        this.text = text;
    }

    public static String getText(Integer code) {
        if (BeanUtils.isNull(code)) {
            return null;
        }
        PayMode[] enums = PayMode.values();
        for (PayMode e : enums) {
            if (Objects.equals(e.code, code)) {
                return e.text;
            }
        }
        return PayMode.NOT_EXISTS.getText();
    }
}
